package com.sun.relationship.m2o;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

@Entity
@Table(name = "DEMO_PROJECT_M2O")
public class ProjectM2O implements Serializable {
	private static final long serialVersionUID = 4025618235520004949L;
	
	private String id;
	private String name;
	private Integer age;
	private Product product;
	private String productId;
	public ProjectM2O() {
	}

	public ProjectM2O(String name, Integer age) {
		super();
		this.name = name;
		this.age = age;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "bizGenerator")
	@GenericGenerator(name = "bizGenerator", strategy = "uuid")
	@Column(length = 32)
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Integer getAge() {
		return age;
	}

	public void setAge(Integer age) {
		this.age = age;
	}

	@ManyToOne(cascade = CascadeType.REFRESH)
	@JoinColumn(name = "PRODUCT_ID")
	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	@Column(name="PRODUCT_ID", updatable=false, insertable=false)
	public String getProductId() {
		return productId;
	}

	public void setProductId(String productId) {
		this.productId = productId;
	}

	@Override
	public String toString() {
		return "ProjectM2O [id=" + id + ", name=" + name + ", age=" + age + ", productId=" + productId + "]";
	}
	
}
